<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: RespondsToParent</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">RespondsToParent</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/active_scaffold/lib/responds_to_parent_rb.html">
                vendor/plugins/active_scaffold/lib/responds_to_parent.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Module containing the methods useful for child IFRAME to parent window
communication
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000465">respond_to_parent</a>&nbsp;&nbsp;
      <a href="#M000464">responds_to_parent</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000465" class="method-detail">
        <a name="M000465"></a>

        <div class="method-heading">
          <span class="method-name">respond_to_parent</span><span class="method-args">(&amp;block)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="RespondsToParent.html#M000464">responds_to_parent</a>
</p>
        </div>
      </div>

      <div id="method-M000464" class="method-detail">
        <a name="M000464"></a>

        <div class="method-heading">
          <a href="#M000464" class="method-signature">
          <span class="method-name">responds_to_parent</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the response body as JavaScript in the context of the parent
window. Use this method of you are posting a form to a hidden IFRAME or if
you would like to use IFRAME base RPC.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000464-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000464-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/responds_to_parent.rb, line 29</span>
29:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">responds_to_parent</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
30:     <span class="ruby-keyword kw">yield</span>
31:     
32:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">performed?</span>
33:       <span class="ruby-comment cmt"># We're returning HTML instead of JS or XML now</span>
34:       <span class="ruby-identifier">response</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">'text/html; charset=UTF-8'</span>
35:       
36:       <span class="ruby-comment cmt"># Either pull out a redirect or the request body</span>
37:       <span class="ruby-identifier">script</span> =  <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">location</span> = <span class="ruby-identifier">erase_redirect_results</span>
38:                   <span class="ruby-node">&quot;document.location.href = #{location.to_s.inspect}&quot;</span>
39:                 <span class="ruby-keyword kw">else</span>
40:                   <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span>
41:                 <span class="ruby-keyword kw">end</span>
42:                 
43:       <span class="ruby-comment cmt"># Escape quotes, linebreaks and slashes, maintaining previously escaped slashes</span>
44:       <span class="ruby-comment cmt"># Suggestions for improvement?</span>
45:       <span class="ruby-identifier">script</span> = (<span class="ruby-identifier">script</span> <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>).
46:         <span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'\\'</span>, <span class="ruby-value str">'\\\\\\'</span>).
47:         <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\r\n|\r|\n/</span>, <span class="ruby-value str">'\\n'</span>).
48:         <span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/['&quot;]/</span>, <span class="ruby-value str">'\\\\\&amp;'</span>).
49:         <span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'&lt;/script&gt;'</span>,<span class="ruby-value str">'&lt;/scr&quot;+&quot;ipt&gt;'</span>)
50: 
51:       <span class="ruby-comment cmt"># Clear out the previous render to prevent double render</span>
52:       <span class="ruby-identifier">erase_results</span>
53:       
54:       <span class="ruby-comment cmt"># Eval in parent scope and replace document location of this frame </span>
55:       <span class="ruby-comment cmt"># so back button doesn't replay action on targeted forms</span>
56:       <span class="ruby-comment cmt"># loc = document.location to be set after parent is updated for IE</span>
57:       <span class="ruby-comment cmt"># with(window.parent) - pull in variables from parent window</span>
58:       <span class="ruby-comment cmt"># setTimeout - scope the execution in the windows parent for safari</span>
59:       <span class="ruby-comment cmt"># window.eval - legal eval for Opera</span>
60:       <span class="ruby-identifier">render</span> <span class="ruby-identifier">:text</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;&lt;html&gt;&lt;body&gt;&lt;script type='text/javascript' charset='utf-8'&gt;
61:         var loc = document.location;
62:         with(window.parent) { setTimeout(function() { window.eval('#{script}'); loc.replace('about:blank'); }, 1) } 
63:       &lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span>
64:     <span class="ruby-keyword kw">end</span>
65:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>